package 继承.继承的应用场景;

//Dog类:{name,age,sex,eat(),watch()};
public class Dog {
    //私有成员变量
    private String name;
    private int age;
    private String sex;

    //无参构造方法
    public Dog() {
    }

    //有参构造方法
    public Dog(String name, int age, String sex) {
        this.age = age;
        this.name = name;
        this.sex = sex;
    }

    //公共成员方法
    public void eat() {
        System.out.println(name+"会吃肉");
    }

    public void watch() {
        System.out.println(name+"会看家");
    }

    //成员变量相应的get/set函数
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }
}
